<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    <link rel="shortcut icon" type="image/x-icon" href="assets/img/favicon.ico">
    <title>Preclinic - Medical & Hospital - Bootstrap 4 Admin Template</title>
    <link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/style.css">
    <!--[if lt IE 9]>
		<script src="assets/js/html5shiv.min.js"></script>
		<script src="assets/js/respond.min.js"></script>
	<![endif]-->
</head>

<body>
            <div class="content">
                <div class="row">
                    <div class="col-sm-5 col-4">
                        <h4 class="page-title">票据</h4>
                    </div>
                    <div class="col-sm-7 col-8 text-right m-b-30">
                        <a href="create-invoice.html" class="btn btn-primary btn-rounded"><i class="fa fa-plus"></i> 新增票据</a>
                    </div>
                </div>
                <div class="row filter-row">
                    <div class="col-sm-6 col-md-3">
                        <div class="form-group form-focus">
                            <label class="focus-label">从</label>
                            <div class="cal-icon">
                                <input class="form-control floating datetimepicker" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-3">
                        <div class="form-group form-focus">
                            <label class="focus-label">到</label>
                            <div class="cal-icon">
                                <input class="form-control floating datetimepicker" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-3">
                        <div class="form-group form-focus select-focus">
                            <label class="focus-label">状态</label>
                            <select class="select floating">
                                <option>请选择状态</option>
                                <option value="待付款">待付款</option>
                                <option value="付清">付清</option>
                                <option value="部分支付">部分支付</option>
								<option value="出票">出票</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-3">
                        <a href="#" class="btn btn-success btn-block"> 查询 </a>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="table-responsive">
                            <table class="table table-striped custom-table mb-0">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>票据编号</th>
                                        <th>患者</th>
                                        <th>创建时间</th>
                                        <th>到期日期</th>
                                        <th>金额</th>
                                        <th>状态</th>
                                        <th class="text-right">操作</th>
                                    </tr>
                                </thead>
                                <tbody id="invoices">                                    
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            
		<div id="delete_invoice" class="modal fade delete-modal" role="dialog">
			<div class="modal-dialog modal-dialog-centered">
				<div class="modal-content">
					<div class="modal-body text-center">
						<h3>Are you sure want to delete this Invoice?</h3>
						<div class="m-t-20"> <a href="#" class="btn btn-white" data-dismiss="modal">Close</a>
							<button type="submit" class="btn btn-danger">Delete</button>
						</div>
					</div>
				</div>
			</div>
		</div>
    <div class="sidebar-overlay" data-reff=""></div>
    <script src="assets/js/jquery-3.2.1.min.js"></script>
	<script src="assets/js/popper.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/jquery.dataTables.min.js"></script>
    <script src="assets/js/dataTables.bootstrap4.min.js"></script>
    <script src="assets/js/select2.min.js"></script>
    <script src="assets/js/jquery.slimscroll.js"></script>
    <script src="assets/js/moment.min.js"></script>
    <script src="assets/js/bootstrap-datetimepicker.min.js"></script>
    <script src="assets/js/app.js"></script>
	<!--json data-->
	<script type="text/javascript" src="json/invoices.json"></script>
	<script type="text/javascript">
	$(document).ready(function () {
		var nowDay = new Date();
		var year = nowDay.getFullYear(); //获取当前年
		var mon = nowDay.getMonth() + 1; //获取当前月
		var date = nowDay.getDate(); //获取当前日
		var time = year + "/" + mon + "/" + date;
		nowDay = new Date(time);
	
		var invoicesStr = "";
		for(var i = 0; i < invoices.length; i++){
			invoicesStr = invoicesStr + '<tr>';
            invoicesStr = invoicesStr + '<td>'+ (i + 1) +'</td>';
            invoicesStr = invoicesStr + '<td><a href="invoice.html?invoiceNum='+invoices[i].num+'">'+ invoices[i].num +'</a></td>';
            invoicesStr = invoicesStr + '<td>'+ invoices[i].patientName +'</td>';
            invoicesStr = invoicesStr + '<td>'+ invoices[i].createTime +'</td>';
            invoicesStr = invoicesStr + '<td>'+ invoices[i].due +'</td>';
            invoicesStr = invoicesStr + '<td>￥'+ invoices[i].amount +'</td>';
            invoicesStr = invoicesStr + '<td><span class="custom-badge ';
			var dueDate = new Date(invoices[i].due.replace("-", "/").replace("-", "/"));
			if(invoices[i].status == "付清"){
				invoicesStr = invoicesStr + 'status-green';
			}else if(invoices[i].status == "出票"){
				invoicesStr = invoicesStr + 'status-blue';
			}else if(dueDate <= nowDay){
				invoicesStr = invoicesStr + 'status-red';
			}else if(invoices[i].status == "部分支付"){
				invoicesStr = invoicesStr + 'status-orange';
			}else if(invoices[i].status == "待付款"){
				invoicesStr = invoicesStr + 'status-red';
			}
			invoicesStr = invoicesStr + '">'+ invoices[i].status +'</span></td>';
            invoicesStr = invoicesStr + '<td class="text-right">';
            invoicesStr = invoicesStr + '<div class="dropdown dropdown-action">';
            invoicesStr = invoicesStr + '<a href="#" class="action-icon dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-ellipsis-v"></i></a>';
            invoicesStr = invoicesStr + '<div class="dropdown-menu dropdown-menu-right">';
            invoicesStr = invoicesStr + '<a class="dropdown-item" href="edit-invoice.html"><i class="fa fa-pencil m-r-5"></i> 编辑</a>';
            invoicesStr = invoicesStr + '<a class="dropdown-item" href="invoice-view.html"><i class="fa fa-eye m-r-5"></i> 查看详情</a>';
            invoicesStr = invoicesStr + '<a class="dropdown-item" href="#"><i class="fa fa-file-pdf-o m-r-5"></i> 下载票据</a>';
			invoicesStr = invoicesStr + '<a class="dropdown-item" href="#" data-toggle="modal" data-target="#delete_invoice"><i class="fa fa-trash-o m-r-5"></i> 删除票据</a>';
            invoicesStr = invoicesStr + '</div></div></td></tr>';
		}
		$("#invoices").html(invoicesStr);
	});
	</script>
</body>

</html>